{extend name="common:main" /}
{block name="cssjs"}
<script src="__PUBLIC__/static/js/admin/tool_json_tree.js?{$Think.config.html_v}"></script>
{/block}
{block name="content"}
<div class="box box-default">
	<div class="box-body">
		<div class="form-group">
			<div class="input-group">
				<textarea id="txt_data" rows="2" class="form-control" placeholder="输入网址或json字符串，网址必须以http://或https://开头">{$data|htmlspecialchars}</textarea>
				<a href="javascript:;" class="input-group-addon" id="btn_tree">确定</a>
			</div>
		</div>
		<div id="tool_json_tree"></div>
	</div>
</div>
<script type="text/javascript">
'use strict';//严格模式
$(document).ready(function(){
	$('#btn_tree').bind('click',function(){
		window.tool_json_tree.treeId='#tool_json_tree';
		var data=$('#txt_data').val();
		if(dataIsJson(data)){
			//是json字符串
			window.tool_json_tree.load(data);
		}else{
			$('#tool_json_tree').html('<div class="loading"></div>');
			ajaxOpen({
				type: 'POST',
				dataType: 'json',
				url: ulink('Tool/json_tree'),
				data: {data:data},
				success: function (data) {
					data=data.data.json;
					window.tool_json_tree.load(data);
				}
			});
		}
	});

	if($('#txt_data').val()){
		//有数据自动提交
		$('#btn_tree').trigger('click');
	}
});
</script>
{/block}